package cn.yshujia.domain.entity;

import cn.yshujia.handler.EncryptionHandler;
import cn.yshujia.handler.PrefixHandler;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * @author YShuJia
 * @create 2024/4/23
 * @description 实体
 */

@Data
@NoArgsConstructor
@TableName (value = "t_user", autoResultMap = true)
@Schema (name = "User", description = "用户")
public class User implements Serializable {
	
	@Serial
	private static final long serialVersionUID = 1L;
	
	public User (Long id, String username, String password, String email, String avatar) {
		this.id = id;
		this.username = username;
		this.password = password;
		this.email = email;
		this.avatar = avatar;
	}
	
	@Schema (description = "主键")
	@TableId (value = "id", type = IdType.ASSIGN_ID)
	private Long id;
	
	@Schema (description = "角色ID")
	@TableField ("role_id")
	private Long roleId;
	
	@Schema (description = "头像")
	@TableField (value = "avatar", typeHandler = PrefixHandler.class)
	private String avatar;
	
	@Schema (description = "用户名")
	private String username;
	
	@Schema (description = "密码")
	@TableField ("`password`")
	private String password;
	
	@Schema (description = "性别 -1女 0保密 1男")
	@TableField ("gender")
	private Integer gender;
	@Schema (description = "邮箱")
	@TableField (value = "email", typeHandler = EncryptionHandler.class)
	private String email;
	
	@Schema (description = "经验值")
	@TableField ("experience")
	private Integer experience;
	
	@Schema (description = "创建时间")
	@TableField (value = "create_time", fill = FieldFill.INSERT)
	@JsonFormat (pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date createTime;
	
	@Schema (description = "状态（0销户，1可用）")
	@TableField ("`status`")
	private Boolean status;
}